home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / dasv10_.arj / MEGADICE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-10  |  1.2 KB  |  63 lines

  1. // dice.lib function mega_dice()
  2. #include <conio.h>
  3. #include <iostream.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6.  
  7. int mega_dice(int,int,int,int,int,int);
  8.  
  9. void main()
  10. {
  11.     randomize();
  12.  
  13. mega_dice(0,0,6,5,1,1);
  14. cout<<"\n";
  15. }
  16.  
  17. int mega_dice(int loc,int user,int size,int indice,int seedice,int seesum)
  18. {
  19.     int dice1,numdice,sum=0;
  20.  
  21. cout<<"\n[C]omputer controlled ? ";
  22.     if (getche()=='c') //begin if
  23.         goto COMPUTE;
  24.     else //else
  25.         goto USERIN;
  26.     //end if
  27.  
  28. USERIN:
  29.     cout<<"\nHow many dice ? ";
  30.     cin>>indice;
  31.     for (numdice=1;numdice<=indice;numdice++) {
  32.         cout<<"Enter roll #"<<numdice<<" ";
  33.         cin>>dice1;
  34.         sum=sum+dice1;
  35.     }//end for
  36. goto END;
  37.  
  38. COMPUTE:
  39. cout<<"\n";
  40.     for (numdice=1;numdice<=indice;numdice++) {//begin for
  41. WAIT:    dice1=1+rand()%size; if (user==1 && getche()!=' ') goto WAIT;
  42.         if (seedice==0 && user==0) //begin if
  43.         cout<<" ?";
  44.         else if (seedice==1 && user==0) //else if
  45.         cout<<" "<<dice1;
  46.         else //else
  47.         cout<<dice1;
  48.         //end if
  49.     sum=sum+dice1;
  50.     if (loc==1) //begin if
  51.         cout<<"\n";
  52.     //end if
  53.     }//end for
  54.  
  55. END:
  56.     if (seesum==0) //begin if
  57.         cout<<" Sum is ?";
  58.     else if (seesum==1) //else if
  59.         cout<<" Sum is "<<sum;
  60.     //end if
  61.  
  62. return sum;
  63. }